package com.wnhz.work.yz.adapter;

import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.wnhz.work.yz.R;
import com.wnhz.work.yz.bean.AllocationBean;
import com.wnhz.work.yz.bean.LookDetailsBean;
import com.wnhz.work.yz.bean.LookDetialNumsBean;

import org.greenrobot.eventbus.EventBus;
import org.xutils.x;

import java.util.List;

/**
 * Created by Administrator on 2017/6/21 0021.
 */

public class Look2ListAdapter extends BaseAdapter {

    private List<LookDetailsBean.InfoEntity.CateInfoEntity.DataEntity> data2;
    private LayoutInflater layoutInflater;
    private Context context;

    public Look2ListAdapter(Context context, List<LookDetailsBean.InfoEntity.CateInfoEntity.DataEntity> data2) {
        this.context = context;
        this.data2 = data2;
        this.layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return data2.size();
    }

    @Override
    public Object getItem(int position) {
        return data2.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        AllocationViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new AllocationViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.all_look_content_item2, null);
            viewHolder.good_logo = (ImageView) convertView.findViewById(R.id.good_logo);
            viewHolder.text_title = (TextView) convertView.findViewById(R.id.text_title);
            viewHolder.text_price = (TextView) convertView.findViewById(R.id.text_price);
            viewHolder.text_desc = (TextView) convertView.findViewById(R.id.text_desc);
            viewHolder.shopping_number = (TextView) convertView.findViewById(R.id.shopping_number);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (AllocationViewHolder) convertView.getTag();
        }

        x.image().bind(viewHolder.good_logo, data2.get(position).getGoods_pic());
        viewHolder.text_title.setText(data2.get(position).getGoods_name());
        viewHolder.text_price.setText("¥" + data2.get(position).getGoods_price() + "/" + data2.get(position).getGoods_unit());
        if (data2.get(position).getGoods_unit() == null || data2.get(position).getGoods_unit().equals("")) {


            viewHolder.text_price.setText("¥" + data2.get(position).getGoods_price() + "/套");
        }
        viewHolder.shopping_number.setText("" + data2.get(position).getGoods_nums());
        viewHolder.text_desc.setText(data2.get(position).getSku_info());

        return convertView;
    }

    class AllocationViewHolder {
        ImageView good_logo, img_toast;
        TextView text_title, text_price, text_desc;
        TextView shopping_number;
    }
}




